
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>CircleU</title>
<?php
 	session_start(); 
	if( !$_SESSION["login"])header('Location: error_page.php');
	include("db_util.php");
	putenv("ORACLE_HOME=/usr/local/libexec/oracle/app/oracle/product/11.2.0/client_1");
	$connection=DbConnect();
	if(!$connection)
		echo "DisConnected!<br>";
	if(isset($_GET["SID"]))$SID=$_GET["SID"]; else $SID=$_SESSION["StuID"];
	$query='SELECT * FROM Student where sid=' . $SID; 
	$statement = oci_parse($connection, $query);
	$query='SELECT name, GID FROM STUGROUP SG, GROUPS G WHERE sg.STUDENTID=' . $SID . 'and G.GID=SG.GroupID';
	$statement1 = oci_parse($connection, $query);
	oci_execute($statement);
	oci_execute($statement1);
	ocifetch ( $statement ) ;
	ocifetch ( $statement1 ) ;
?>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--

a:link   {
text-decoration:   none;
}
a:visited   {
text-decoration:   none;
}
a:hover   {
text-decoration:   underline;
} 
.try {
	background-color: #FFFFFF;
	position: relative;
	z-index: auto;
	visibility: visible;
	clip: rect(auto,auto,auto,auto);
	width: auto;
	height: 76px;
}
.copyright {
	position: absolute;
	left: 150px;
	top: 600px;
	font-size: large;
	height: 22px;
}
.LayerImg {
	left: auto;
}
.CircleU {
	font-family: "Comic Sans MS";
	font-size: xx-large;
	font-weight: bold;
	position: relative;
	left: 20px;
	top: auto;
	height: auto;
	width: auto;
	visibility: visible;
	background-position: left;
	color: #3333FF;
}

#Title1 {
	position:absolute;
	width:1096px;
	height:60px;
	z-index:2;
	left: 9px;
	top: 6px;
}



}

#Dwt01 {
	position:absolute;
	width:1092px;
	height:500px;
	right: 9px;
	top: 80px;
}
#LeftLayer {
	position:absolute;
	width:200px;
	height:500px;
	z-index:3;
	left: 11px;
	top: 77px;
	background-color: #FF6600;
}
#EditR1 {
	position:absolute;
	width:878px;
	height:500px;
	z-index:4;
	left: 221px;
	top: 77px;
}
.STYLE3 {color: #0000CC}
-->
</style><script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<center>
  <div id="Title1">
    <table width="1092" height="59" bgcolor="#FF6600">
      <tr>
        <td rowspan="2" class="CircleU"><div align="left"><?php echo "<a href=\"index.php\">"; ?> <span class="STYLE3">CircleU</a></span></div></td>
        <td width="128"><div align="right"><?php echo "<a href=\"Personal.php\">"; ?> My Page </a></div></td>
        <td width="111"><div align="right"><?php echo "<a href=\"SignOut.php\">"; ?>Sign Out </a></div></td>
        <td width="120"><div align="center"><?php echo "<a href=\"ContactUs.php\">"; ?>Contact Us</a></div></td>
      </tr>
      <tr>
        <td><form id="form2" name="form2" method="post" <?php echo "action=\"AdvancedSearch.php\""; ?>>
          <label>
            <input type="submit" name="AdvancedSearch" value="Advanced Search" />
          </label>
        </form>
        </td>
        <td colspan="2"><form id="form1" name="form1" method="post" <?php echo "action=\"SearchResult.php\""; ?>>
          <label>
            <input type="text" name="SearchText" />
          </label>
          <label>
          <input type="submit" name="SearchResult" value="search" />
          </label>
        </form>        </td>
      </tr>
    </table>
  </div>
  <div class="copyright">
<p>Copyright @ 2011 CircleU built in University of Florida. All right reserved&#13;</p>

</div>

 
  
  

  <div id="LeftLayer">
  <div id="Layerleft2">
  <?php

  if(isset($_GET["GSID"]))echo "<a href=PictureView.php?GSID=" . OCIResult( $statement, 'SID' ). "><img src=\"". OCIResult( $statement, 'PROFILE_PIC' ) . "\" width=\"200\" height=\"133\" /></a>";
  else echo "<a href=PictureView.php><img src=\"". OCIResult( $statement, 'PROFILE_PIC' ) . "\" width=\"200\" height=\"133\" /></a>";
 
  ?>
  </div>
  <div id="Layerleft3">
  <?php 
  
  
  function MostPopularCourse($connection)
	{
	
	$query='select courseid, cname, max(savg) from (select courseid, avg(score) as savg, count(*) as cnum from courseReview cr, CoursePost cp where cr.CPID=cp.CPID group by CourseID having count(*)>=2) res, course c where c.cid=res.courseid group by courseid, cname';
	
	$MostPopularCourse = oci_parse($connection, $query);
	oci_execute($MostPopularCourse);
	return $MostPopularCourse;
	}
  
  function AddAsFriend($connection)
	{
	$query='Insert into isfriend values(' . $_SESSION["StuID"] . ',' . $_GET["GSID"] . ')'; 
	$InsertRelationShip = oci_parse($connection, $query);
	oci_execute($InsertRelationShip);
	oci_free_statement($InsertRelationShip)	;
	$query='Insert into isfriend values(' . $_GET["GSID"] . ',' . $_SESSION["StuID"] . ')'; 
	$InsertRelationShip = oci_parse($connection, $query);
	oci_execute($InsertRelationShip);
	oci_free_statement($InsertRelationShip)	;
	}
	
	 function RemoveFriend($connection)
	{
	$query='Delete from isfriend where (s1=' . $_SESSION["StuID"] . ' and s2=' . $_GET["GSID"] . ') or (s1=' . $_GET["GSID"] . 'and s2=' . $_SESSION["StuID"] . ')'; 
	$DeleteRelationShip = oci_parse($connection, $query);
	oci_execute($DeleteRelationShip);
	
	oci_free_statement($DeleteRelationShip)	;
	}
	
	if(isset($_POST["Remove"]))RemoveFriend($connection);
	else
	{
	if(isset($_POST["Add"]))AddAsFriend($connection);
	}
	
  
  if(!isset($_GET["GSID"])) echo "<a href=\"ProfileSetting.php\">Profile Setting</a>"; else 
 {
 	$query='SELECT * FROM ISFRIEND where (s1=' . $_SESSION["StuID"] . ' and s2=' . $_GET["GSID"] . ') or (s1=' . $_GET["GSID"] . ' and s2=' . $_SESSION["StuID"] . ')'; 
	$checkIfFriend = oci_parse($connection, $query);
	oci_execute($checkIfFriend);
  echo "<form id=\"removeoradd\" name=\"removeoradd\" method=\"post\" action=\"\">" . "<input type=\"submit\" "; if(ocifetch($checkIfFriend)) echo "name=\"Remove\" value=\"Remove\""; else echo "name=\"Add\" value=\"Add as friend\"";
 oci_free_statement($checkIfFriend); echo "/></form>"; 
 } 
  ?>
    <table width="200" border="1" bgcolor="#FF6600" id="profile" style="table-layout: fixed;" >
	<tr>
        <td width="84"><span class="STYLE4">First Name: </span></td>
        <td width="100"><?php
  echo OCIResult( $statement, 'FIRST_NAME' );
  ?></td>
      </tr>
	  <tr>
        <td width="84"><span class="STYLE4">Last Name: </span></td>
        <td width="100"><?php
  echo OCIResult( $statement, 'LAST_NAME' );
  ?></td>
      </tr>
      <tr>
        <td width="84"><span class="STYLE4">Department: </span></td>
        <td width="100"><?php
  echo OCIResult( $statement, 'DEPARTMENT' );
  ?></td>
      </tr>
      <tr>
        <td><span class="STYLE4">Birthday:</span></td>
        <td><?php
  echo OCIResult( $statement, 'BIRTHDAY' );
  ?></td>
      </tr>
      
      <tr>
        <td><span class="STYLE4">Hobbies:</span></td>
        <td><?php
  echo OCIResult( $statement, 'HOBBIES' );
  ?></td>
      </tr>
     <tr>
	 
        <td width="84"><span class="STYLE4"><?php 
	 if(isset($_GET["GSID"]))
	 echo "<a href=\"PictureView.php?GSID=" . $SID . "\"> Album </a></span>"; else  
	 echo "<a href=\"PictureView.php\"> Album </a></span>";
	 ?></td>
      
      </tr>
      <tr>
        <td style= "word-break:break-all;"><span class="profile">Groups:</span></td>
       <?php echo "<td style= \"word-break:break-all; width:40\">"; while(ocifetch($statement1)){echo "<a href=\"GroupPage.php?GID=" . OCIResult( $statement1, 'GID' ) . "\">" .
 OCIResult( $statement1, 'NAME' ) . ";</a>";} 
	
  ?></td>  </tr>
   <tr>
        <td><span class="profile">Courses:</span></td>
       <?php echo "<td>"; while(ocifetch($statement2)){echo "<a href=\"CourseHome.php?CID=" . OCIResult( $statement2, 'CID' ) . "\">" .
 OCIResult( $statement2, 'CID' ) . ";</a>";} 
  ?></td>      </tr>
 
  
  <?php 
  if(!isset($_GET["GSID"])){
  echo "<tr>
        
		<td width=\"84\"><span class=\"STYLE4\"><a href=\"FriendList.php\"> Friends </a></span> </td>
      
      </tr>";
  }
  ?>
   <tr>
        <td></td>
       <td></td>      </tr>
  
   <tr>
        <td><span class="profile">MVP Courses:</span></td>
       <?php echo "<td>"; $temp=MostPopularCourse($connection);ocifetch($temp); echo "<a href=\"CourseHome.php?CID=" . OCIResult( $temp, 'COURSEID' ) . "\">" .
 OCIResult( $temp, 'COURSEID' ) . ";</a>"; oci_free_statement($statement);oci_free_statement($statement1);oci_free_statement($statement2);
 oci_free_statement($temp);
	oci_close($connection);
  ?></td>      </tr>
  
     
    </table>
  </div>
  
  </div>
  <div id="EditR1"><!-- InstanceBeginEditable name="EditRegion3" --><?php
  putenv("ORACLE_HOME=/usr/local/libexec/oracle/app/oracle/product/11.2.0/client_1");
	$connection=DbConnect();
	
	$query='SELECT * FROM GroupPost where GRID=' . $_GET["GPID"]; 
	$statement = oci_parse($connection, $query);
	oci_execute($statement);
	
	$query='SELECT * FROM Student, GroupPost where GPID=' . $_GET["GPID"] . " and sid=author and GRID=0"; 
	$statement2 = oci_parse($connection, $query);
	oci_execute($statement2);
ocifetch ( $statement2 );
	
	
  ?>
  <div id="Layer1">
    <table width="731" height="277" border="0">
	
	<?php
	echo "<tr>
        <td width=\"725\" height=\"141\"><table width=\"634\" height=\"57\" border=\"0\">
          <tr>
            <td width=\"80\" height=\"80\" rowspan=\"2\"><img src=\"" . OCIResult( $statement2, 'PROFILE_PIC' ) . "\" width=\"80\" height=\"80\" /></td>
            <td width=\"518\" height=\"16\"><a href=Personal.php?SID=" . OCIResult( $statement2, 'SID' ) . ">" . OCIResult( $statement2, 'FIRST_NAME' ) . " " . OCIResult( $statement2, 'LAST_NAME' ) . " </a>       </td>
          </tr>
          <tr>
            <td height=\"35\">" . OCIResult( $statement2, 'CONTENT' ) . "</td>
          </tr>
        </table>
          <hr /></td>
      </tr>";
	while(ocifetch ( $statement )) {

	$query='SELECT * FROM student where sid=' . OCIResult( $statement, 'AUTHOR' ); 
	$statement1 = oci_parse($connection, $query);
	oci_execute($statement1);
	ocifetch ( $statement1 );
	echo "<tr>
        <td width=\"725\" height=\"141\"><table width=\"634\" height=\"57\" border=\"0\">
          <tr>
            <td width=\"100\" rowspan=\"2\"><img src=\"" . OCIResult( $statement1, 'PROFILE_PIC' ) . "\" width=\"80\" height=\"80\" /></td>
            <td width=\"518\" height=\"16\"><a href=Personal.php?SID=" . OCIResult( $statement1, 'SID' ) . ">" . OCIResult( $statement1, 'FIRST_NAME' ) . " " . OCIResult( $statement1, 'LAST_NAME' ) . " </a>       </td>
          </tr>
          <tr>
            <td height=\"35\">" . OCIResult( $statement, 'CONTENT' ) . "</td>
          </tr>
        </table>
          <hr /></td>
      </tr>";
	}
	?>
     
	  
	  
      
    </table>
  </div><!-- InstanceEndEditable --></div>
</center>
</body>
<!-- InstanceEnd --></html>
